/*******************************************************************
 *   > File Name: debug.h
 *   > Author: fly
 *   > Mail: 1358326274@qq.com
 *   > Create Time: 2020年07月16日 星期四 23时45分42秒
 ******************************************************************/
#ifndef __DEBUG_H__
#define __DEBUG_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <string.h>

#define DBG_PRINTF_FUNC     1
#define DBG_PRINTF_SWITCH   1
#define COLOR_DEBUG_FUNC    1

// color debug
#ifdef COLOR_DEBUG_FUNC
#define NONE    "\e[m"
#define RED     "\e[0;31m"
#define GREEN   "\e[0;32m"
#define YELLOW  "\e[0;33m"
#define BLUE    "\e[0;34m"
#else
#define NONE
#define RED
#define GREEN
#define YELLOW
#define BLUE
#endif

#define NEWLINE "\n"
#define debug_msg   printf

#ifdef DBG_PRINTF_FUNC
#define DBG_PRINTF(fmt, args...)        \
    do{\
        debug_msg("["BLUE"%s"NONE"]("GREEN"%d"NONE"):",\
                __func__, __LINE__);\
        debug_msg(fmt, ##args);\
    }while(0)

#define DBG_PRINTF_K(key, fmt, args...)     \
    if(key){\
        debug_msg("["BLUE"%s"NONE"]("GREEN"%d"NONE"):",\
                __func__, __LINE__);\
        debug_msg(fmt, ##args);\
    }
#define DBG_WRN(fmtstr, args...) debug_msg("\e[33m%s(): \e[0m" fmtstr,__func__, ##args)
#define DBG_ERR(fmtstr, args...) debug_msg("\e[31m%s(): \e[0m" fmtstr,__func__, ##args)
#else
#define DBG_PRINTF(fmt, args...)
#define DBG_PRINTF_K(key, fmt, args...)
#define DBG_WRN(fmt, args...)
#define DBG_ERR(fmt, args...)    
#endif

#ifdef __cplusplus
}
#endif

#endif /* __DEBUG_H__ */
